package zdyu.data_structures.linked_list;

import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.stream.IntStream;

import static org.junit.jupiter.api.Assertions.*;

class LinkedListTest {

    LinkedList<String> list = new LinkedList<>();

    LinkedListTest() {
        list.add("hello");
        list.add("world");
        list.add("!");
    }

    @Test
    void add() {
        list.add("hello");
        list.add("world");
        System.out.println(list);
        System.out.println(list.size());
    }

    @Test
    void toArray() {
        System.out.println(Arrays.toString(list.toArray()));
    }


    @Test
    void contains() {
        System.out.println(list.contains("hell"));
        System.out.println(list.contains("world"));
    }

    @Test
    void removeIndex() {
        System.out.println(list.remove(0));
        System.out.println(list);
    }

    @Test
    void removeElement() {
        System.out.println(list.remove("hell"));
        System.out.println(list);
        System.out.println(list.remove("world"));
        System.out.println(list);
    }

    @Test
    void clear() {
        list.clear();
        System.out.println(list);
        System.out.println(list.size());
        System.out.println(list.isEmpty());
    }

    @Test
    void get() {
        IntStream.range(0, list.size()).forEach(i -> {
            System.out.println(list.get(i));
        });
    }

    @Test
    void set() {
        list.set(0, "hell");
        list.set(2, "?");
        System.out.println(list);
    }

    @Test
    void indexOf() {
        System.out.println(list.indexOf(""));
        System.out.println(list.indexOf("!"));
    }
}